#Common variables
$identityStoreURI = "LDAP://localhost:61000/O=Extranet"

#LitwareHR Administrator Data
$userCpn = "admin@Extranet"
$userPassword = "saasy"
$userEmail = "admin@Extranet.com"
$userCN = "cn=admin"
$userName = "admin"

#Create Users organizational unit

$extranetAdam = [ADSI]"LDAP://localhost:61000/O=Extranet"
$usersOU = $extranetAdam.Create("organizationalUnit", "OU=Users")
$usersOU.SetInfo()

#Create User (LitwareHR Administrator)
$adminUser = $usersOU.Create("User", $userCN)
$adminUser.Put("userPrincipalName", $userCpn)
$adminUser.Put("mail", $userEmail)
$adminUser.SetInfo()
$adminUser.Put("userPassword", $userPassword)
$adminUser.Put("msDs-UserAccountDisabled", $false)
$adminUser.SetInfo()
$adminUser = [ADSI]"LDAP://localhost:61000/CN=admin, OU=Users, O=Extranet"
 

#Add User to Administrators Group
$administratorGroup = [ADSI]"LDAP://localhost:61000/CN=Administrators, CN=Roles, O=Extranet"
$groupMemebers= $administratorGroup.Member
$administratorGroup.Member = $groupMemebers + $adminUser.distinguishedName
$administratorGroup.SetInfo()


